<template>
  <Particles class="bg-background-light"></Particles>
  <Suspense>
    <router-view v-slot="{ Component }">
    <keep-alive>
      <component :is="Component" v-if="$route.meta.keepAlive" />
    </keep-alive>
    <component :is="Component" v-if="!$route.meta.keepAlive" />
  </router-view>
  </Suspense>

</template>

<script setup>
import Particles from '@/components/particle/index.vue'
// import showDialog from './libs/dialog/showDialog.js'
import { onBeforeUnmount, onMounted } from 'vue'
import { PutViewCounts } from './api/Desktop/website/index.js'
// import { getSign } from './api/Desktop/admin/getSign.js'
//通过唯一标识判断判断用户是否为今日首次进入网站如果是则调用增加访客函数

PutViewCounts()
// PutViewCounts()
function handleBeforeUnload() {
  //清除一下本地缓存
  window.localStorage.removeItem('repairRecords')
  window.localStorage.removeItem('userMessageRecord')
  window.localStorage.removeItem('fileContent')
}
onMounted(() => {
  // 添加监听事件
  window.addEventListener('beforeunload', handleBeforeUnload)
})

onBeforeUnmount(() => {
  // 组件销毁时移除监听事件，避免内存泄漏
  window.removeEventListener('beforeunload', handleBeforeUnload)
})
</script>
<style lang="scss" scoped></style>
